// pages/content/alonesinger.js
Page({

    /**
     * 页面的初始数据
     */
    data: {
        // songs: [
        //     {
        //         order: 1,
        //         songName: "本草纲目",
        //         singer: "周杰伦"
        //     },
        //     {
        //         order: 2,
        //         songName: "Papillon",
        //         singer: "王嘉尔"
        //     },
        //     {
        //         order: 3,
        //         songName: "Papillon",
        //         singer: "王嘉尔"
        //     },
        //     {
        //         order: 4,
        //         songName: "Papillon",
        //         singer: "王嘉尔"
        //     },
        //     {
        //         order: 5,
        //         songName: "Papillon",
        //         singer: "王嘉尔"
        //     }
        // ]
        songs:[],
        singer:[],
        concert:[{introduction:'我最近没有演唱会哦O(∩_∩)O哈哈~'}],
        Time:''
    },

    gotoPlay(e) {
        var eid = e.target.id || e.currentTarget.id;
        var Eid = eid.substring(1);
        var songID = Eid.slice(0, Eid.indexOf(','));
        var songIDs = [];
        var songName = Eid.slice(Eid.indexOf(',')+1);
        var songNames = [];

        for(var i=0; i<this.data.songs.length; i++) {
            songIDs.push(this.data.songs[i].id);
            songNames.push(this.data.songs[i].name);
        }
        wx.navigateTo({
          url: '../newplay/newplay?name='+songName+'&names='+songNames+'&id='+songID+'&ids='+songIDs,
        })
    },

    /**
     * 生命周期函数--监听页面加载
     */
    onLoad: function (options) {
        let that=this
        wx.request({
            url: 'http://49.233.35.127/Wx/Getsong/',
            data:{name:options.key},
            success:function(res) {  
                that.setData({
                    songs:res.data
                })
            }
        })
        wx.request({
            url: 'http://49.233.35.127/Wx/GetsingerByname/',
            data:{name:options.key},
            success:function(res) {
                that.setData({
                    singer:res.data
                })
            }
        })
        wx.request({
            url: 'http://49.233.35.127/Wx/Getconcert/',
            data:{name:options.key},
            success:function(res) {
                that.setData({
                    concert:res.data,
                    Time:res.data[0].time
                }) 
            }
        })
    },

    /**
     * 生命周期函数--监听页面初次渲染完成
     */
    onReady: function () {

    },

    /**
     * 生命周期函数--监听页面显示
     */
    onShow: function () {

    },

    /**
     * 生命周期函数--监听页面隐藏
     */
    onHide: function () {

    },

    /**
     * 生命周期函数--监听页面卸载
     */
    onUnload: function () {

    },

    /**
     * 页面相关事件处理函数--监听用户下拉动作
     */
    onPullDownRefresh: function () {

    },

    /**
     * 页面上拉触底事件的处理函数
     */
    onReachBottom: function () {

    },

    /**
     * 用户点击右上角分享
     */
    onShareAppMessage: function () {

    }
})